#include <iostream>
using namespace std;
#include "brass.h"
const int CLIENTS = 4;
const int LEN = 40;

// 使用指针或者引用来实现多态
int main() {
  Brass *p_clients[CLIENTS];

  int i;
  for (i = 0; i < CLIENTS; i++) {
    char temp[LEN];
    long tempnum;
    double tempbal;
    char kind;
    cout << "enter client's name:";
    cin.getline(temp, LEN);

    cout << "enter client accent number:";
    cin >> tempnum;
    cout << "enter opening balance:";
    cin >> tempbal;
    cout << "enter 1 for brass accent or " << " 2 for brassplus accent:";
    while (cin >> kind && (kind != '1' && kind != '2')) {
      cout << "enter 1 or 2";
    }
    if (kind == '1') {
      p_clients[i] = new Brass(temp, tempnum, tempbal);
    } else {
      double tmax, trate;
      cout << "enter the overdraft limit:";
      cin >> tmax;
      cout << "enter the interest rate" << "as a decimal fraction:";
      cin >> trate;
      p_clients[i] = new BrassPlus(temp, tempnum, tempbal, tmax, trate);
    }
    while (cin.get() != '\n') {
      continue;
    }
  }

  cout << endl;
  for (i = 0; i < CLIENTS; i++) {
    p_clients[i]->ViewAcct();
    cout << endl;
  }

  for (i = 0; i < CLIENTS; i++) {
    delete p_clients[i];
  }
  cout << "done ..." << endl;

  return 0;
}
